package com.zifan.st_geometry.controller;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zifan.st_geometry.service.STGeometryService;

@Controller
@RequestMapping("/stGeometry")
@RestController
public class STGeometyController {

	@Autowired
	private STGeometryService service;

	@RequestMapping(value="/intersect",method=RequestMethod.POST)
	public List<HashMap<String, Object>> interect(@RequestParam String tableName, @RequestParam(required=false) String[] fields, @RequestParam String wkt, @RequestParam int srId) {
		return service.queryIntersect(tableName, fields, wkt, srId);
	}
	
	@RequestMapping(value="/intersect",method=RequestMethod.GET)
	public List<HashMap<String, Object>> interect(@RequestParam String srcTableName, @RequestParam String targetTableName, @RequestParam(required=false) String[] fields,
			@RequestParam String where, @RequestParam int srId) {
		return service.queryIntersect(srcTableName, targetTableName, fields, where, srId);
	}
}
